package com.karaoke.android.kege.widget

import android.content.Context
import android.util.AttributeSet
import android.widget.ImageView

/**
 * Created by Allen on 16/9/9.
 */
class SquareImageView @JvmOverloads constructor(context: Context, attrs: AttributeSet?, defStyleAttr: Int = 0) : ImageView(context, attrs, defStyleAttr)
{
    override fun onMeasure(widthMeasureSpec: Int, heightMeasureSpec: Int)
    {
        setMeasuredDimension(getDefaultSize(0, widthMeasureSpec), getDefaultSize(0, heightMeasureSpec))
        val childWidthSize = measuredWidth;
        var childHeightSize = measuredHeight;
        //高度和宽度一样
        val h = MeasureSpec.makeMeasureSpec(childWidthSize, MeasureSpec.EXACTLY)
        val w = MeasureSpec.makeMeasureSpec(childWidthSize, MeasureSpec.EXACTLY)
        super.onMeasure(w, h)
    }
}